package com.zoop.controller;

import java.io.IOException;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.SolrDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController 
@RequestMapping("/solr")
public class SolrController {

	@Autowired
	private SolrClient solrClient;
	
	@RequestMapping(value="/queryById")
	public Object queryById() {
		try {
			SolrDocument document = solrClient.getById("new_core", "1");
			return document.toString();
		} catch (SolrServerException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
